{extend name="public/common"}

{block name="style"}
<title>点对点教育VIP学员_测试统计</title>
<style>
	.main{
		background-color:#fff;
	}
	.main>ul>li{
		width:100%;
		padding:2.67vw 0;
		position:relative;
		background:url("__HOME__/images/sign/rightArr.png") no-repeat center right;
		background-size:7.5vw 7.5vw;
		border-bottom:0.27vw solid #eee;
		height: 26vw;
	}
	.main>ul>li .a1{
		width: 88vw;
		position:absolute;
		left: 5vw;
		overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		font-size: 1.46rem;
		color: #333333;
	}
	.main>ul>li .a2{
		width: 88vw;
		top: 10vw;
		position:absolute;
		left: 5vw;
		overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		font-size: 1.46rem;
		color: #333333;
	}
	.start{
		color:#666;
		position:absolute;
		bottom: 2.67vw;;
		right:5vw;
		font-size:1.3rem;
	}
	.nomessage{
		text-align: center;
		position:fixed;
		top:50%;
		left:50%;
		-webkit-transform: translateY(-50%) translateX(-50%);
	}
	.nomessage>img{
		width:56%;
		margin-bottom:4vw;
	}
	.nomessage>span{
		font-size: 1.7rem;
		color:#ccc;
	}
</style>
{/block}

{block name="body"}
<div class="scroll"  style="position:absolute; overflow:scroll; -webkit-overflow-scrolling: touch; top:0; left:0; bottom:0; right:0">
<div class="main" >
	<ul>
		{empty name="list"}
		<div class="nomessage">
			<img src="__HOME__/images/sign/5.png" alt="" ><br>
			<span>抱歉，暂无数据</span>
		</div>
		{else/}
		{volist name="list" id="vo"}
		<li data-num="" onclick="window.location.href='detail?code={$vo.code}'; $(this).css('backgroundColor','#eee');" class="clearfix">
			<p class="a1">【{$vo.class}】、【{$vo.class1}】、【{$vo.class2}】</p>
			<p class="a2">【{$vo.class3}】、【{$vo.class4}】</p>
			<span class="start">【测试开始】：{$vo.time}</span>
		</li>
		{/volist}
		{/empty}
	</ul>
</div>
<div class="tip"></div>
<div class="loading hidden">
	<div class="typing_loader"></div>
</div>
	</div>
{/block}

{block name="script"}
<script src="__HOME__/js/reset.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
	$('title' ).text('点对点教育VIP学员_测试统计');
    //关闭分享
    function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
    }
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
	var scrollNow = true;//判断下拉请求是否执行中.false为正在请求
	$(function(){
		//初始化数据
		var len = $(".main").find("li").length;
		if(len >=20){
			$('.tip').text('上拉加载更多');
			document.getElementsByClassName("scroll")[0].addEventListener('scroll',handleScroll);
		}else{
			document.getElementsByClassName("scroll")[0].removeEventListener("scroll",handleScroll);
			$('.tip').hide();
		}
	});
	var handleScroll = function() {
		var tip = $(".tip");
		var len = $(".main").find("li").length;
		var loading = $('.loading');
		var el = document.getElementsByClassName("scroll")[0];
		if(el.scrollTop + el.offsetHeight +2 >= el.scrollHeight && scrollNow){
			scrollNow = false;
			tip.show().text('上拉加载更多');
			$.ajax({
				type: 'post',
				url: "{:Url('Scan/testmore')}",
				data: {
					length:len,
				},
				beforeSend: function(XMLHttpRequest){
					tip.hide();
					loading.toggleClass('hidden');
				},
				success: function (res) {
					loading.toggleClass('hidden');
					tip.show();
					if(res.code == 1){
						addNews(res);
						if(res.data.length==20){
							tip.text('上拉加载更多');
						}else{
							tip.text('没有更多了');
							document.getElementsByClassName("scroll")[0].removeEventListener("scroll",handleScroll);
						}
					}else{
						tip.text('没有更多了');
						document.getElementsByClassName("scroll")[0].removeEventListener("scroll",handleScroll);
					}
					scrollNow = true;
				},error:function(data){

				}
			});
		}
	};
	function addNews(data){
		var html = '';
		var lists = data.data;
		var len = lists.length;
		for(var i = 0; i< len;i++){
			var list = lists[i];
			html +=
					'<li data-num="'+list.id+'" onclick="window.location.href='+"'"+'detail?code=' +list.code +"'; $(this).css('backgroundColor','#eee');"+'"class="clearfix" class="a1">'+
					'<p class="a1">【'+list.class+'】、【'+list.class1+'】、【'+list.class2+'】</p>'+
					'<p class="a2">【'+list.class3+'】、【'+list.class4+'】</p>'+
					'<span class="start">【测试开始】：'+list.time+'</span>'+
					'</li>'
		}
		$(".main").find("ul").append(html);
	}
</script>
{/block}